package com.lognsoft.btest;

import java.lang.String;
import java.util.ArrayList;

public class ResultCompare 
{

public static boolean Compare (String resultFile, String answerFile)
{
	ArrayList<String> answerLines;
	ArrayList<String> resultLines;
	
	try
	{
		answerLines = FileOp.getLinesFromFile(answerFile);
		resultLines = FileOp.getLinesFromFile(resultFile);
	}
	catch (Exception e)
	{
		return false;
	}
	
	if (   answerLines == null 
		|| resultLines == null 
		|| answerLines.size() != resultLines.size() )
	{
		return false;
	}
	
	for (int i = 0; i < answerLines.size(); i++)
	{
		String answerLine = answerLines.get(i);
		String resultLine = resultLines.get(i);
		
		if (answerLine.startsWith(TestCaseDef.BTestPrefix))
		{
			int from = TestCaseDef.BTestPrefix.length();
			int ind  = answerLine.indexOf(' ', from);
			
			if (ind < 0)
			{
				return false;
			}
			
			boolean match_bl = BTest_match(
					answerLine.substring(from, ind),
					answerLine.substring(ind+1),
					resultLine);
			
			if (match_bl == false)
			{
				return false;
			}
			else
			{
				continue;
			}
		}
		
		if (false == answerLine.equals(resultLine))
		{
			return false;
		}
	}
	
	return true; 
}

private static boolean BTest_match (String type, String match, String line)
{
	if (type.equals("comment"))
	{
		return true;
	}
	
	return true;
}


}
